package com.byzoro.config;

import com.byzoro.utils.Upload;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/login").setViewName("login");
        registry.addViewController("/index").setViewName("index");
        registry.addViewController("/modelList").setViewName("modelList");
        registry.addViewController("/modelAdd").setViewName("modelAdd");
        registry.addViewController("/userList").setViewName("userList");
        registry.addViewController("/userAdd").setViewName("userAdd");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(Upload.mapPath + "**").addResourceLocations("file:" + Upload.rootPath + Upload.staticPath);
        registry.addResourceHandler(Upload.mapMusicPath + "**").addResourceLocations("file:" + Upload.rootPath + Upload.staticMusicPath);
    }
}
